package xyz.xtt.asset.client;

import java.math.BigDecimal;
import java.util.Collection;
import java.util.List;
import java.util.Map;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;

import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import xyz.xtt.asset.api.enums.AssetTypeEnum;
import xyz.xtt.asset.client.request.AssetNoInfoRequest;
import xyz.xtt.asset.client.request.CancelTransactionRequest;
import xyz.xtt.asset.client.request.CardInfoRequest;
import xyz.xtt.asset.client.request.ConfirmTransactionRequest;
import xyz.xtt.asset.client.request.DeliverRequest;
import xyz.xtt.asset.client.request.MakeTransactionRequest;
import xyz.xtt.asset.client.request.MintRequest;
import xyz.xtt.asset.client.request.ThirdOrderRequest;
import xyz.xtt.asset.client.request.TransferFromRequest;
import xyz.xtt.asset.client.response.AssetAccountResponse;
import xyz.xtt.asset.client.response.AssetAllInfoResponse;
import xyz.xtt.asset.client.response.AssetDetailInfo;
import xyz.xtt.asset.client.response.AssetExtInfoResponse;
import xyz.xtt.asset.client.response.AssetGroupResponse;
import xyz.xtt.asset.client.response.AssetInfoResponse;
import xyz.xtt.asset.client.response.AssetNoResponse;
import xyz.xtt.asset.client.response.AssetStaticResponse;
import xyz.xtt.asset.client.response.AssetTransactionResponse;
import xyz.xtt.asset.client.response.AssetUserLogResponse;
import xyz.xtt.asset.client.response.AssetVo;
import xyz.xtt.asset.client.response.BlindBoxDetailResponse;
import xyz.xtt.asset.client.response.CancelOrderResponse;
import xyz.xtt.asset.client.response.ConfirmOrderResponse;
import xyz.xtt.asset.client.response.MintResponse;
import xyz.xtt.asset.client.response.NftListVo;
import xyz.xtt.asset.client.response.TblAssetCardDto;
import xyz.xtt.asset.client.response.TblAssetExpandDto;
import xyz.xtt.asset.client.response.TblAssetNoDto;
import xyz.xtt.asset.client.response.TransactionResponse;
import xyz.xtt.asset.client.response.TransferFromResponse;
import xyz.xtt.common.response.ApiResult;

@FeignClient(name = "nft-asset", fallbackFactory = AssetClientFallbackFactory.class)
public interface AssetClient {
	/**
	 * 权益竞换
	 * 
	 * @param deliverRequest
	 * @return
	 */
	@PostMapping("/api/asset/nft/create")
	public ApiResult<MintResponse> create(@RequestHeader("uid") String uid, @RequestBody @Valid MintRequest mintRequest);

	@PostMapping("/api/asset/nft/mint")
	public ApiResult<MintResponse> mint(@RequestHeader("uid") String uid, @RequestBody @Valid MintRequest mintRequest);

	@PostMapping("/api/asset/nft/transferFrom")
	public ApiResult<TransferFromResponse> transferFrom(@RequestHeader("platform") String platform,
			@RequestBody @Valid TransferFromRequest transferFromRequest);

//	/**
//	 * 查询待支付订单
//	 * 
//	 * @param fetchRequest
//	 * @return
//	 */
//	@PostMapping("/api/asset/order/fetchUnPaid")
//	ApiResult<List<TblPayOrderDto>> fetchUnPaidOrders(@RequestBody FetchUnPaidOrdersRequest fetchRequest);

	/**
	 * 支付订单状态确认
	 * 
	 * @param confirmRequest
	 * @return
	 */
//	@PostMapping("/api/asset/order/confirmPayStatus")
//	ApiResult<Boolean> confirmPayStatus(@RequestBody @Valid ConfirmPayOrderRequest confirmRequest);

	/**
	 * 获取支付订单状态
	 * 
	 * @param request
	 * @return
	 */
//	@PostMapping("/api/asset/order/getPayStatus")
//	ApiResult<Integer> getPayStatus(@RequestBody @NotNull GetPayStatusRequest request);

	/**
	 * 批量获取支付订单状态
	 * 
	 * @param request
	 * @return
	 */
//	@PostMapping("/api/asset/order/getPayStatusMap")
//	ApiResult<Map<Long, Integer>> getPayStatusMap(@RequestBody @Valid GetPayStatusMapRequest request);

	/**
	 * 风格使用次数统计
	 * 
	 * @return
	 */
	@GetMapping("/api/nft/asset/collection/statis")
	ApiResult<Map<Long, Long>> collectionStatis();
//
//	/**
//	 * 玫瑰
//	 * 
//	 * @return
//	 */
//	@GetMapping("/api/asset/rose/statis")
//	ApiResult<Map<Long, Long>> roseStatis();

//	/**
//	 * 发送小助手消息
//	 * 
//	 * @param request
//	 * @return
//	 */
//	@PostMapping("/api/asset/assistant/msg")
//	ApiResult<Boolean> assistantMessage(@RequestBody AssistantMessageRequest request);

//	@GetMapping("/api/asset/order/fetch")
//	ApiResult<TblPayOrderDto> fetchPayOrder(@RequestParam(value = "payOrderId") Long payOrderId);

	@PostMapping("/api/nft/asset/assetCard/getUserCardInfo")
	ApiResult<List<TblAssetCardDto>> getUserCardInfo(@RequestBody CardInfoRequest cardInfoRequest);

//	@PostMapping("/api/asset/businessOrder/selectListByGoodsIds")
//	ApiResult<List<BusinessOrderDto>> selectListByGoodsIds(@RequestBody BusinessOrderRequest businessOrderRequest);

//	@PostMapping("/api/asset/businessOrder/getByIds")
//	ApiResult<Map<Long, BusinessOrderDto>> getBusinessListByIds(@RequestBody Set<Long> ids);

//	@RequestMapping("/api/asset/fund/account/getNeedSettleRecords")
//	ApiResult<List<TblUserFundRecordDto>> getNeedSettleRecords(@RequestParam("maxCount") @Positive Integer maxCount,
//			@RequestParam(value = "lastId", required = false) Long lastId);
//
//	@PostMapping("/api/asset/fund/account/updateFundSettled")
//	ApiResult<Boolean> updateFundSettled(@RequestBody @Valid UpdateFundSettledRequest request);

	/**
	 * 查资产详情
	 * 
	 * @param goodsId
	 * @return
	 */
	@GetMapping("/api/nft/asset/info/goodsId")
	ApiResult<AssetInfoResponse> infoWithGoodsId(@RequestParam("goodsId") String goodsId);

	/**
	 * 查资产详情
	 * 
	 * @param assetId
	 * @return
	 */
	@GetMapping("/api/nft/asset/info/assetId")
	ApiResult<AssetInfoResponse> infoWithAssetId(@RequestParam("assetId") Long assetId);

	/**
	 * 查资产扩展信息
	 * 
	 * @param assetId
	 * @return
	 */
	@GetMapping("/api/nft/asset/ext/infoWithAssetId")
	ApiResult<AssetExtInfoResponse> extInfoWithAssetId(@RequestParam("assetId") Long assetId);

	/**
	 * 查资产资源信息
	 * 
	 * @param assetId
	 * @return
	 */
	@GetMapping("/api/nft/asset/info/assetId")
	ApiResult<AssetStaticResponse> staticInfoWithAssetId(@RequestParam("assetId") Long assetId);

	/**
	 * 查资产的所有详情信息 根据goodsId
	 * 
	 * @param assetId
	 * @return
	 */
	@GetMapping("/api/nft/asset/info/goodsId")
	ApiResult<AssetAllInfoResponse> infoGoodsId(@RequestParam("goodsId") String goodsId);

	/**
	 * 批量查资产的所有详情信息 根据goodsId
	 * 
	 * @param goodsIds
	 * @return
	 */
	@GetMapping("/api/nft/asset/batchInfo/goodsId")
	ApiResult<Map<String, AssetAllInfoResponse>> batchInfoGoodsIds(@RequestParam("goodsId") Collection<String> goodsIds);

	/**
	 * 查资产的所有详情信息 根据assetId
	 * 
	 * @param assetId
	 * @return
	 */
	@GetMapping("/api/nft/asset/info/assetId")
	ApiResult<AssetAllInfoResponse> infoAssetId(@RequestParam("assetId") Long assetId);

	/**
	 * 批量查资产的所有详情信息 根据assetId
	 * 
	 * @param assetIds
	 * @return
	 */
	@GetMapping("/api/nft/asset/batchInfo/assetId")
	ApiResult<Map<Long, AssetAllInfoResponse>> batchInfoAssetId(@RequestParam("assetId") Collection<Long> assetIds);

	/**
	 * 查资产的所有详情信息
	 * 
	 * @param assetId
	 * @return
	 */
	@GetMapping("/api/nft/asset/index/list")
	ApiResult<List<NftListVo>> index(@RequestHeader("uid") Long uid, @RequestParam(value = "type", defaultValue = "1") Integer type,
			@RequestParam(value = "currPage", defaultValue = "1") Integer currPage, @RequestParam(value = "pageSize", defaultValue = "20") Integer pageSize,
			@RequestParam(value = "sortType", defaultValue = "") String sortType, @RequestParam(value = "sortOrder", defaultValue = "desc") String sortOrder);

	/**
	 * 某有资产的详情 检查余额
	 * 
	 * @param assetId
	 * @return
	 */
	@GetMapping("/api/nft/asset/accountInfoCheckAmount")
	ApiResult<AssetAccountResponse> accountInfoCheckAmount(@RequestParam("assetId") Long assetId, @RequestParam("appUid") Long appUid);

	/**
	 * 某有资产的详情 不检查余额
	 * 
	 * @param assetId
	 * @return
	 */
	@GetMapping("/api/nft/asset/accountInfoUnCheckAmount")
	ApiResult<AssetAccountResponse> accountInfoUnCheckAmount(@RequestParam("assetId") Long assetId, @RequestParam("appUid") Long appUid);

	@GetMapping("/api/nft/asset/queryNotPaiedPersonalMintUpChaninOrder")
	ApiResult<TransactionResponse> queryNotPaiedPersonalMintUpChaninOrder(@RequestParam("assetId") Long assetId, @RequestParam("appUid") String appUid);

	@GetMapping("/api/nft/asset/queryNotPayOrder")
	ApiResult<TransactionResponse> queryNotPayOrder(@RequestParam("assetId") Long assetId, @RequestParam("appUid") String appUid);

	@GetMapping("/api/nft/asset/queryPaySyncOne")
	ApiResult<TransactionResponse> queryPaySyncOne(@RequestParam("buyUserId") String buyUserId, @RequestParam("orderId") Long orderId);

	/**
	 * 历史最大成交价
	 * 
	 * @param appUid
	 * @param goodsId
	 * @return
	 */
	@GetMapping("/api/nft/asset/buyMaxPriceWithHistory")
	ApiResult<BigDecimal> buyMaxPriceWithHistory(@RequestParam("appUid") String appUid, @RequestParam("goodsId") String goodsId);

	/**
	 * 资产群信息
	 * 
	 * @param assetId
	 * @return
	 */
	@GetMapping("/api/nft/asset/group")
	ApiResult<AssetGroupResponse> group(@RequestParam("assetId") Long assetId);

	/**
	 * 上架数量
	 * 
	 * @param uid
	 * @return
	 */
	@GetMapping("/api/nft/asset/queryPutOn")
	ApiResult<Long> queryPutOn(@RequestParam("uid") String uid);

	@PostMapping("/api/nft/asset/transaction/makeTransaction")
	ApiResult<AssetTransactionResponse> makeTransaction(@RequestBody @Valid MakeTransactionRequest makeOrder);

	@PostMapping("/api/nft/asset/transaction/cancelTransaction")
	ApiResult<CancelOrderResponse> cancelTransaction(@RequestBody @Valid CancelTransactionRequest cancelTransactionRequest);

	@PostMapping("/api/nft/asset/transaction/confirmTransaction")
	ApiResult<ConfirmOrderResponse> confirmTransaction(@RequestBody @Valid ConfirmTransactionRequest confirmTransactionRequest);

	@GetMapping("/api/nft/asset/hasGift365")
	ApiResult<Boolean> hasGift365(Long appUid);

	@GetMapping("/api/nft/asset/getAssetExpand")
	ApiResult<TblAssetExpandDto> getAssetExpand(@RequestParam("assetId") @NotNull Long assetId);

	@GetMapping("/api/nft/asset/transactionInfo")
	ApiResult<TransactionResponse> transactionInfo(@RequestParam("orderId") Long orderId);

	@GetMapping("/api/nft/asset/queryAssetType")
	ApiResult<List<AssetVo>> queryAssetType(@RequestParam("currPage") Integer currPage, @RequestParam("uid") String uid,
			@RequestParam("type") AssetTypeEnum type);

	@GetMapping("/api/nft/asset/queryBlindBoxDetail")
	ApiResult<List<BlindBoxDetailResponse>> queryBlindBoxDetail(@RequestParam("goodsId") List<String> goodsId);

	@GetMapping("/api/nft/asset/lastConfig")
	ApiResult<AssetUserLogResponse> lastConfig(@RequestParam("assetId") Long assetId);

	@PostMapping("/api/nft/asset/saveUpChainFlag")
	ApiResult<Boolean> saveUpChainFlag(@RequestParam("appUid") String appUid, @RequestParam("businessRefId") Long businessRefId);

	@PostMapping("/api/nft/asset/adjustPopularityRate")
	ApiResult<Boolean> adjustPopularityRate(@RequestParam("goodsId") String goodsId, @RequestParam("targetValue") int targetValue);

	@PostMapping("/api/nft/asset/thirdOrder")
	ApiResult<MintResponse> thirdOrder(@RequestBody ThirdOrderRequest payOrderDto);

	@PostMapping("/api/asset/assetNo/getNFTNoInfo")
	ApiResult<List<TblAssetNoDto>> getNFTNoInfo(@RequestBody AssetNoInfoRequest assetNoInfoRequest);

	@GetMapping("/api/asset/accountInfoWithId")
	ApiResult<AssetAccountResponse> accountInfoWithId(@RequestParam("accountId") Long accountId);

	@GetMapping("/api/nft/asset/card/assetNoInfoWithNoId")
	ApiResult<AssetNoResponse> assetNoInfoWithNoId(@RequestParam("noId") Long noId);

	@GetMapping("/api/nft/asset/detailInfo")
	ApiResult<AssetDetailInfo> detailInfo(@RequestParam("uid") String uid, @RequestParam("goodsId") String goodsId, @RequestParam("accountId") Long accountId);

	/**
	 * 权益竞换
	 * 
	 * @param deliverRequest
	 * @return
	 */
	@PostMapping("/api/nft/asset/deliver")
	ApiResult<Boolean> deliver(@RequestBody @Valid DeliverRequest deliverRequest);
}
